<?php

/* 
 * The include path may change 
 * depending on PHPCodeProvider.php location. 
 */

include_once 'Classes/PHPCodeProvider.php';

/*
 * Create an instance of the CodeGeneratorOptions class
 * using the default options for code generation.
 */

$options = new CodeGeneratorOptions();

/*
 * Create an instance of the IndentedTextWriter.
 */

$writer = new IndentedTextWriter();

/*
 * Create a class declaration
 */

$class1 = new TypeDeclaration('myClass');

/*
 * Create a method declaration and add it to the class
 */

$method4 = new Method('MyMethod');
$class1->Members->add($method4);

/*
 * Create two parameters, 
 * one with a type hint and one with a default value
 */

$parameter1 = new ParameterDeclarationExpression('subject');
$parameter1->TypeHint = new TypeReference('SplSubject');

$parameter2 = new ParameterDeclarationExpression('option');
$parameter2->DefaultValue = new PrimitiveExpression(false);

/*
 * Add parameters to the method
 */

$method4->Parameters->add($parameter1);
$method4->Parameters->add($parameter2);

/*
 * Generate the code and output the result.
 */

$provider = new PHPCodeProvider();
$provider->generateCodeFromType($class1, $writer, $options);
echo 
    '<pre>' . str_replace(
        '<br />', '', highlight_string($writer->get_String(), true)) . 
    '<pre/>';

/*
 * The output should be:
 * 
 * class myClass 
 * {
 *   
 *     public function MyMethod (SplSubject $subject, $option = false)
 *     {
 *     }
 * }
 * 
 */


?>
